<?php
class Cache999
{
	var $dir='cache999';
	function read($key,$second){
		$d=$this->dir;
		$f="$d/$key.txt";
	 	if(!file_exists($d))mkdir($d);
	 	$ftime=file_exists($f)?filemtime($f):0;
		$expire=$ftime+$second<mktime();
	 	if($expire)return false;
		return unserialize(file_get_contents($f));
	}
	function write($key,$newdata){
		$d=$this->dir;
		$f="$d/$key.txt";
		$fp=fopen($f,'w');
		$data=serialize($newdata);
		fwrite($fp,$data);
		fclose($fp);
		return $newdata;
	}
}

?>